<?php
namespace app\payqr\model;
use AlibabaCloud\Client\AlibabaCloud;
use app\BaseModel;
class CardConfig extends BaseModel
{
    protected $name = 'longbing_card_config';
    public function getinfo($where){
        return $this->where($where)->find();
    }
    //短信发送
    public function sendSms($str_phone,$keyId,$keySecret,$SignName,$TemplateCode){
        AlibabaCloud::accessKeyClient($keyId, $keySecret)->regionId('cn-hangzhou') // replace regionId as you need
        ->asDefaultClient();

        try {
            $result = AlibabaCloud::rpc()
                ->product('Dysmsapi')
                // ->scheme('https') // https | http
                ->version('2017-05-25')
                ->action('SendSms')
                ->method('POST')
                ->host('dysmsapi.aliyuncs.com')
                ->options([
                    'query' => [
                        'RegionId' => "default",
                        'PhoneNumbers' => $str_phone,
                        //必填项 签名(需要在阿里云短信服务后台申请)
                        'SignName' => $SignName,
                        //必填项 短信模板code (需要在阿里云短信服务后台申请)
                        'TemplateCode' => $TemplateCode,
                        //如果在短信中添加了${code} 变量则此项必填 要求为JSON格式
                        //'TemplateParam' => "{'code':'123123'}",
                    ],
                ])
                ->request();
            return $result->toArray();
        } catch (ClientException $e) {
            return $e->getErrorMessage();
        } catch (ServerException $e) {
            return $e->getErrorMessage();
        }
    }
}